#!/usr/bin/perl

sub ValuesForXML($$);

my $SRCROOT = $ENV{"SRCROOT"};
my @paths = ();
my $opened;

# 6318295
local $/;
$opened = open (FILE, "$SRCROOT/Library/QuickTimeStreamingServer/Config/streamingserver.xml");
if ($opened) {
	my $xmlData = <FILE>;
	push @paths, ValuesForXML($xmlData, "broadcast_dir_list");
	push @paths, ValuesForXML($xmlData, "movie_folder");
	push @paths, ValuesForXML($xmlData, "redirect_broadcasts_dir");
	push @paths, ValuesForXML($xmlData, "request_logfile_dir");
	push @paths, ValuesForXML($xmlData, "mp3_request_logfile_dir");
	push @paths, ValuesForXML($xmlData, "error_logfile_dir");
	push @paths, ValuesForXML($xmlData, "module_folder");
	push @paths, ValuesForXML($xmlData, "request_logfile_dir");
	close (FILE);
}

# 6318295
$opened = opendir(DIR, "$SRCROOT/private/var/spool/");
if ($opened) {
	my @chatpaths = readdir(DIR);
	foreach my $path (@chatpaths) {
		push @paths, "/private/var/spool/$path" if ($path =~ /conference\..*/);
	}
	closedir(DIR);
}

# 6336815
my $wikipath = `/usr/libexec/PlistBuddy -c "print repositoryPath" \Q$SRCROOT\E/etc/wikid/wikid.conf 2>/dev/null`;
if (!$?) {
	chomp $wikipath;
	push @paths, $wikipath;
}

foreach my $path (@paths) {
	print "$path\n";
}

sub ValuesForXML($$) {
	my ($xmlData, $key) = @_;
	
	my @values = ();
	my @lines = split '\n', $xmlData;
	my $eat_values = 0;
	foreach my $line (@lines) {
		if ($eat_values && $line =~ /<VALUE>(.*)<\/VALUE>/) {
			push @values, $1 if $1 ne "";
		}
		
		if ($eat_values && $line =~ /<\/LIST-PREF>/) {
			last;
		}
		
		if ($line =~ /.*PREF.*NAME="$key".*>(.*)<.*/) {
			return $1 if $1 ne "";
		} elsif ($line =~ /.*LIST-PREF.*NAME="$key".*/) {
			$eat_values = 1;
		}
	}
	
	return @values;
}